<?php
require_once 'include.php';
require_once '_functions.php';

if (!isset($_POST['realname']) || !isset($_POST['email']) ||!isset($_POST['password']) || !isset($_POST['password2'])) {
	echo 'This page should not be accessed directly!';
} else if ($_POST['password'] != $_POST['password2']) {
	echo 'Passwords not equal.';
} else {	
	try {
		Connect();
		$i = addAdmin($_POST['realname'], $_POST['email'], md5($_POST['password']));
		echo 'Registration successfully completed with id ' . $i . '. Your account is now awaiting approval by the girafPlace administrators';
	} catch (InvalidArgumentException $e) {
		echo ($e->getMessage());
	}
}